using System.Web.UI;
using System.Web.UI.WebControls;

namespace newtelligence.DasBlog.Web.Core
{
    /// <summary>
    /// Converts the TextBox control to the interface needed by dasBlog
    /// </summary>
    public class TextBoxAdapter : EditControlAdapter
    {
        private readonly TextBox _Control;

        public TextBoxAdapter()
        {
            _Control = new TextBox();
            _Control.ID = "editControl";
            _Control.TextMode = TextBoxMode.MultiLine;
        }

        public override Control Control
        {
            get { return _Control; }
        }

        public override string Text
        {
            get { return _Control.Text; }
            set { _Control.Text = value; }
        }

        public override Unit Width
        {
            get { return _Control.Width; }
            set { _Control.Width = value; }
        }

        public override Unit Height
        {
            get { return _Control.Height; }
            set { _Control.Height = value; }
        }

        public override bool HasText()
        {
            return (_Control.Text.Trim().Length > 0 && _Control.Text.Trim() != "<p></p>");
        }
    }
}